#ifndef TCL_USB_H
#define TCL_USB_H
#include <QString>
#include <QDataStream>
#include<QFile>
#include <QVector>
#include"tcl_tv.h"
#include "tcl_mtk_atv_tv.h"
#include "tcl_mtk_dtv_tv.h"
#include "tcl_mstar_atv_tv.h"
#include "tcl_mstar_dtv_tv.h"

#ifndef DATA_STRUCT_H
#define DATA_STRUCT_H
#include "data_struct.h"
#endif




class TCL_USB
{
    friend class MainWindow;
public:
    TCL_USB();
    // TCL_USB(bool exist);
    // TCL_USB(bool exist,bool info);
    //  TCL_USB(bool exist=false, bool info1=false, bool info2=false);
 TCL_USB(QString &file,bool info1=false,bool info2=false):
            read_info(info1),write_info(info2),file_name(file){}

 ~TCL_USB();
    int Read_File(QDataStream &,QString);
    // int Read_File();
    int Write_File(QDataStream &);

    void Del_ATV_Row(int list,int );
    void Del_DTV_Row(int list,int);
    //    int Write_File();
 //   int Operator_File(QDataStream &,bool Rd_We);
private:
    int Read_MTK_Data(QDataStream &,int dtv_atv_flag);
    int Write_MTK_Data(QDataStream&,int dtv_atv_flag);
    int Read_MSTAR_Data(QDataStream &,int dtv_atv_flag);
    int Write_MSTAR_Data(QDataStream &,int dtv_atv_flag);
    void Clear_MTK_ATV();
    void Clear_MTK_DTV();
    void Clear_MSTAR_ATV();
    void Clear_MSTAR_DTV();

 private :
 //   bool ch_is_exist;
    bool read_info;
    bool write_info;
    uint u4_count;
    uint empty;
    //文件头标志
    qint8 solution;//低四位有效
    qint8 dtv_atv_flag;//
    qint8 version;
    //  qint32 dtv_atv_length;
    QString file_name;
    BIN_FILE_HEADER file_header;


    bool Bin_Header_Test(BIN_FILE_HEADER&);
    //
public:
    //暂时保存频道信息
     QList<TCL_MTK_ATV_TV*> q_mtk_atv_tv;
     QList<TCL_MTK_DTV_TV*> q_mtk_dtv_tv;
     QList<TCL_MSTAR_ATV_TV*> q_mstar_atv_tv;
     QList<TCL_MSTAR_DTV_TV*>q_mstar_dtv_tv;
 public :
    void set_mtk_atv(int ,int,QVariant );
    void set_mtk_dtv(int,int,QVariant );
    void set_mstar_atv(int,int,QVariant );
   void  set_mstar_dtv(int,int,QVariant );
     void set_count(const uint num);
     void set_dtv_atv_flag(const qint8  flag);
     void set_solution(const qint8 solution);

    int Get_Solution();

     bool is_empty();
     void set_Empty();
     void Empty_Add_One();
     void Empty_Del_One();
     void Add_ATV_CH(TCL_MSTAR_ATV_TV*);
     void Clear();
     void Add_DTV_CH(TCL_MSTAR_DTV_TV *);
     void Add_DTV_CH(TCL_MTK_DTV_TV *);


};

#endif // TCL_USB_H
